package com.bbzn.device.client.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.DataType;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.concurrent.TimeUnit;

@Component
public class VideoUtils<T> {

    @Autowired
    private StringRedisTemplate redisTemplate;

    /*  2021.07.02 用于APP视频功能：关注*/

    //保存用户关注数据的key
    public static final String MAP_KEY_USER_FOLLOW = "MAP_USER_FOLLOW";
    //保存用户被关注数量的key
    public static final String MAP_KEY_USER_FOLLOW_COUNT = "MAP_USER_FOLLOW_COUNT";

    /*  2021.07.07 用于APP视频功能：点赞*/
    //保存用户点赞数据的key
    public static final String MAP_KEY_USER_LIKED = "MAP_USER_LIKED";
    //保存用户被点赞数量的key
    public static final String MAP_KEY_USER_LIKED_COUNT = "MAP_USER_LIKED_COUNT";


    /**
     * 拼接被关注的用户手机号和关注的人的手机号作为key。格式 222222::333333
     * @param followUserPhone 被关注的人id
     * @param followPostPhone 关注的人的id
     * @return
     */
    public static String getFollowKey(String followUserPhone, String followPostPhone){
        StringBuilder builder = new StringBuilder();
        builder.append(followUserPhone);
        builder.append("::");
        builder.append(followPostPhone);
        return builder.toString();
    }

    /**
     * 拼接视频id和点赞的人的手机号作为key。格式 222222::333333
     * @param videoId 被点赞的人id
     * @param likedUserPhone 点赞的人的id
     * @return
     */
    public static String getLikedKey(String videoId, String likedUserPhone){
        StringBuilder builder = new StringBuilder();
        builder.append(videoId);
        builder.append("::");
        builder.append(likedUserPhone);
        return builder.toString();
    }
}
